home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / TUTORIAL.BIN / IO.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-01-30  |  2.6 KB  |  88 lines

  1. package symantec.itools.db.net;
  2.  
  3. import java.io.IOException;
  4. import java.io.InputStream;
  5. import java.io.OutputStream;
  6. import java.net.Socket;
  7. import symjava.sql.SQLException;
  8.  
  9. // $FF: renamed from: symantec.itools.db.net.IO
  10. class class_0 {
  11.    Socket _sock;
  12.    InputStream _userIS;
  13.    OutputStream _readerOS;
  14.    OutputStream _userOS;
  15.    SocketWriter _writer;
  16.    SocketReader _reader;
  17.    short _id;
  18.  
  19.    class_0(MPlex mplex, Socket s, short streamID) throws NetException {
  20.       try {
  21.          this._sock = s;
  22.          this._id = streamID;
  23.          this._userIS = new SocketIS(this._sock.getInputStream(), mplex);
  24.          this._writer = new SocketWriter(this._sock.getOutputStream());
  25.          this._userOS = new NetOutputStream(this._writer, streamID);
  26.       } catch (IOException var4) {
  27.          throw new NetException("Error constructing IO object");
  28.       } catch (SQLException var5) {
  29.          throw new NetException("Error constructing IO object");
  30.       }
  31.    }
  32.  
  33.    class_0(SocketWriter ostr, short streamID) throws NetException {
  34.       try {
  35.          this._sock = null;
  36.          this._id = streamID;
  37.          this._userIS = new NetPipedInputStream();
  38.          this._readerOS = new NetPipedOutputStream((NetPipedInputStream)this._userIS);
  39.          this._userOS = new NetOutputStream(ostr, streamID);
  40.          this._reader = null;
  41.          this._writer = ostr;
  42.       } catch (IOException var3) {
  43.          throw new NetException("Error constructing IO object");
  44.       }
  45.    }
  46.  
  47.    class_0(SocketWriter ostr, InputStream istr, short streamID) throws NetException {
  48.       this._sock = null;
  49.       this._id = streamID;
  50.       this._userIS = istr;
  51.       this._readerOS = null;
  52.       this._userOS = new NetOutputStream(ostr, streamID);
  53.       this._reader = null;
  54.       this._writer = ostr;
  55.    }
  56.  
  57.    void close() {
  58.       if (this._reader != null && this._reader.isAlive()) {
  59.          this._reader.stop();
  60.  
  61.          while(this._reader.isAlive()) {
  62.             try {
  63.                Thread.sleep(10L);
  64.             } catch (Exception var3) {
  65.             }
  66.          }
  67.       }
  68.  
  69.       try {
  70.          if (this._sock != null) {
  71.             this._sock.close();
  72.             return;
  73.          }
  74.       } catch (Exception e) {
  75.          ((Throwable)e).printStackTrace();
  76.       }
  77.  
  78.    }
  79.  
  80.    InputStream getInputStream() {
  81.       return this._userIS;
  82.    }
  83.  
  84.    OutputStream getOutputStream() {
  85.       return this._userOS;
  86.    }
  87. }
  88.